<?php

class Core_Model_Customer_Collection_Showroom_Certificate extends Dcmp_Model_Collection_Strong {

    public function __construct() {
        parent::__construct();
        $this->setItemClass('customer/showroom_certificate');
        $this->from('{t}customer_showroom_certificate', 'a')->field('a.*')
        	 ->filterByStatus('published');
    }
    
    public function joinAccount(){
    	return $this->innerJoin('{t}permission_account', 'b', 'b.id', 'a.mender_id')
    				->field('b.user_name', 'mender');
    }

    public function filterBy($name, $arg) {
        switch ($name) {
        	case 'status':
        		return $this->eq('a.status', ':status:s')->addParameter('status', $arg);
        	case 'showroomid':
        		return $this->eq('a.showroom_id', ':showroomId:i')->addParameter('showroomId', $arg);
        }
        return $this;
    }

}